﻿using StyleCop;
using StyleCop.CSharp;

namespace Jsl.StyleCop.CSharp.OrderingRules
{
    /// <summary>
    /// Rules for ordering elements.
    /// </summary>
    [SourceAnalyzer(typeof(CsParser))]
    public class RuleAnalyzer : SourceAnalyzer
    {
        /// <summary>
        /// Members should be in alphabetically order.
        /// </summary>
        public static readonly string MembersMustBeInAlphabeticalOrder = "MembersMustBeInAlphabeticalOrder";

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="RuleAnalyzer"/> class.
        /// </summary>
        public RuleAnalyzer()
        {
        }
        #endregion Constructors

        #region Public Methods
        /// <summary>
        /// Analyzes the document.
        /// </summary>
        /// <param name="document">The document to analyze.</param>
        public override void AnalyzeDocument(CodeDocument document)
        {
            RuleAnalyzerHelper.AnalyzeDocumentRules(
                document,
                new MembersMustBeInAlphabeticalOrder(this));
        }
        #endregion Public Methods
    }
}